moved to grids/howDidWeDo
<cfabort>

<cfsetting requesttimeout="60">

<!--- <link rel="stylesheet" href="//www.google.com/cse/style/look/default.css" type="text/css" />
<script id="jqueryui" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js" defer async></script>
<script src="//www.google.com/jsapi?key=AIzaSyCMjPkFCRWVdZ5HlAlc8tp_v8gike4HzxI"></script>
<script src="//maps.google.com/maps?file=api&v=2&key=AIzaSyCMjPkFCRWVdZ5HlAlc8tp_v8gike4HzxI" type="text/javascript"></script> --->

<cfif IsUserInRole("Super User") or IsUserInRole("Regional Admin")>

	<cfparam name="resetFilters" default="false">
	<cfset isFiltered = false />
	<cfset queryParams = StructNew() />
	<!--- programYears --->
	<cfif NOT IsDefined("client.howDidWeDo.programYears") or resetFilters>
		<cfset client.howDidWeDo.programYears = request.currentProgramYear>
	<cfelseif IsDefined("filterProgramYear")>
		<cfset client.howDidWeDo.programYears = filterProgramYear>
	</cfif>
	<cfif client.howDidWeDo.programYears neq request.currentProgramYear>
		<cfset isFiltered = true />
		<cfset queryParams.programYears = client.howDidWeDo.programYears />
	<cfelse>
		<cfset queryParams.programYears = request.currentProgramYear />
	</cfif>
	<!--- workshopIDs --->
	<!--- <cfif NOT IsDefined("client.howDidWeDo.workshopIDs") or resetFilters>
		<cfset client.howDidWeDo.workshopIDs = "All">
	<cfelseif IsDefined("filterWorkshopIDs")>
		<cfset client.howDidWeDo.workshopIDs = filterWorkshopIDs>
	</cfif>
	<cfif client.howDidWeDo.workshopIDs neq "All">
		<cfset isFiltered = true />
		<cfset queryParams.workshopIDs = client.howDidWeDo.workshopIDs />
	</cfif> --->
	<!--- countyIDs --->
	<cfif NOT IsDefined("client.howDidWeDo.countyIDs") or resetFilters>
		<cfset client.howDidWeDo.countyIDs = "All">
	<cfelseif IsDefined("filterCountyIDs")>
		<cfset client.howDidWeDo.countyIDs = filterCountyIDs>
	</cfif>
	<cfif client.howDidWeDo.countyIDs neq "All">
		<cfset isFiltered = true />
		<cfset queryParams.countyIDs = client.howDidWeDo.countyIDs />
		<cfset filterCountyIDs = "All" />
	</cfif>
	<!--- zipCodeIDs --->
	<cfif NOT IsDefined("client.howDidWeDo.zipCodeIDs") or resetFilters>
		<cfset client.howDidWeDo.zipCodeIDs = "All">
	<cfelseif IsDefined("filterZipCodeIDs")>
		<cfset client.howDidWeDo.zipCodeIDs = filterZipCodeIDs>
	</cfif>
	<cfif client.howDidWeDo.zipCodeIDs neq "All">
		<cfset isFiltered = true />
		<cfset queryParams.zipCodeIDs = client.howDidWeDo.zipCodeIDs />
		<cfset filterZipCodeIDs = "All" />
	</cfif>
	<!--- cityIDs --->
	<cfif NOT IsDefined("client.howDidWeDo.cityIDs") or resetFilters>
		<cfset client.howDidWeDo.cityIDs = "All">
	<cfelseif IsDefined("filterCityIDs")>
		<cfset client.howDidWeDo.cityIDs = filterCityIDs>
	</cfif>
	<cfif client.howDidWeDo.cityIDs neq "All">
		<cfset isFiltered = true />
		<cfset queryParams.cityIDs = client.howDidWeDo.cityIDs />
		<cfset filterCityIDs = "All" />
	</cfif>
	<!--- districtIDs --->
	<cfif NOT IsDefined("client.howDidWeDo.districtIDs") or resetFilters>
		<cfset client.howDidWeDo.districtIDs = "All">
	<cfelseif IsDefined("filterDistrictIDs")>
		<cfset client.howDidWeDo.districtIDs = filterDistrictIDs>
	</cfif>
	<cfif client.howDidWeDo.districtIDs neq "All">
		<cfset isFiltered = true />
		<cfset queryParams.districtIDs = client.howDidWeDo.districtIDs />
		<cfset filterDistrictIDs = "All" />
	</cfif>
	<!--- schoolIDs --->
	<cfif NOT IsDefined("client.howDidWeDo.schoolIDs") or resetFilters>
		<cfset client.howDidWeDo.schoolIDs = "All">
	<cfelseif IsDefined("filterSchoolIDs")>
		<cfset client.howDidWeDo.schoolIDs = filterSchoolIDs>
	</cfif>
	<cfif client.howDidWeDo.schoolIDs neq "All">
		<cfset isFiltered = true />
		<cfset queryParams.schoolIDs = client.howDidWeDo.schoolIDs />
		<cfset filterSchoolIDs = "All" />
	</cfif>
	
	<cfif IsUserInRole("Super User")>
		<cfif NOT IsDefined("client.howDidWeDo.regionIDs") or resetFilters>
			<cfset client.howDidWeDo.regionIDs = "All">
		<cfelseif IsDefined("filterRegionIDs")>
			<cfset client.howDidWeDo.regionIDs = filterRegionIDs>
		</cfif>
	<cfelseif IsUserInRole("Regional Admin")>
		<cfset client.howDidWeDo.regionIDs = request.authUser.regionID>
	</cfif>
	<cfif client.howDidWeDo.regionIDs neq "All">
		<cfset isFiltered = true />
		<cfset queryParams.regionIDs = client.howDidWeDo.regionIDs />
	</cfif>
	
	<cfif NOT IsDefined("client.howDidWeDo.organizationIDs") or resetFilters>
		<cfset client.howDidWeDo.organizationIDs = "All">
	<cfelseif IsDefined("filterOrganizationIDs")>
		<cfset client.howDidWeDo.organizationIDs = filterOrganizationIDs>
	</cfif>
	<cfif client.howDidWeDo.organizationIDs neq "All">
		<cfset isFiltered = true />
		<cfset queryParams.organizationIDs = client.howDidWeDo.organizationIDs />
		<cfset filterRegionIDs = "All" />
	</cfif>
	
	<cfwddx action="cfml2wddx" input="#queryParams#" output="client.howDidWeDo.queryParamsWDDX" />

	<cfscript>
		//workshopGateway = new assets.calgrants.com.gateway.WorkshopGateway();
		//workshops = workshopGateway.query(Program_Year = queryParams.programYears, Approved = 1, regionIDs = IIf(IsUserInRole("Regional Admin"), request.authUser.regionID, queryParams.regionIDs));
		organizationGateway = new assets.calgrants.com.gateway.OrganizationGateway();
		organizations = organizationGateway.query(regionIDs = IIf(IsUserInRole("Regional Admin"), request.authUser.regionID, ""), Organization_ID = IIf(IsUserInRole("Organizer") OR IsUserInRole("Site Contact"), request.authUser.organizationID, ""));
		storedProcedureGateway = new assets.calgrants.com.gateway.StoredProcedureGateway();
		regions = storedProcedureGateway.call("getDistinctRegions");
		countyGateway = new assets.calgrants.com.gateway.CountyGateway();
		counties = countyGateway.query();
		evaluationGateway = new assets.calgrants.com.gateway.EvaluationGateway();
		evaluations = evaluationGateway.report(argumentCollection = queryParams);
		if (ArrayLen(evaluations) gt 0) {
			evaluationCount = evaluations[1].Response_Count + evaluations[1].No_Response_Count;
		} else {
			evaluationCount = 0;
		}
	</cfscript>
	
	<cfdump var="#evaluations#">
	<cfabort>
	
	<h3>How Did We Do<cfif isFiltered> <small><em>filtered</em></small></cfif></h3>
	
	<cfoutput>
	 
		<!--- <div class="row-fluid" style="margin-bottom: 10px;">
			<div class="span12">
				<a id="filterLink" href="##" class="btn" onclick="toggleFilter('filter')">Show filters</a>
				<!--- <div class="btn-group">
					<button class="btn dropdown-toggle" data-toggle="dropdown">Actions</button>
					<button class="btn dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
					<ul class="dropdown-menu">
						<cfif ArrayLen(evaluations) gt 0>
							<li><a href="?action=export&collection=evaluations" target="_new">Export</a></li>
						</cfif>
					</ul>
				</div> --->
				<span class="pull-right"><strong>Count:</strong> #evaluationCount#</span>
			</div>
		</div> --->

	</cfoutput>
		
	<cfif ArrayLen(evaluations) gt 0>
	
		<script type="text/javascript">
			
			var parseQuestions = function(questions) {
				for (var q = 0; q < questions.length; q++) {
					questions[q].QUESTION_NUMBER = parseInt(questions[q].QUESTION_NUMBER);
					questions[q].RESPONSE_COUNT = parseInt(questions[q].RESPONSE_COUNT);
					questions[q].MULTI_RESPONSE_COUNT = parseInt(questions[q].MULTI_RESPONSE_COUNT);
					questions[q].NO_RESPONSE_COUNT = parseInt(questions[q].NO_RESPONSE_COUNT);
				}
				return questions;
			}
			
			var parseAnswers = function(answers) {
				for (var a = 0; a < answers.length; a++) {
					if (answers[a].ANSWER === true) {
						answers[a].ANSWER = "Yes ";
					} else if (answers[a].ANSWER === false) {
						answers[a].ANSWER = "No ";
					}
					answers[a].ANSWER_NUMBER = parseInt(answers[a].ANSWER_NUMBER);
					answers[a].RESPONSE_COUNT = parseInt(answers[a].RESPONSE_COUNT);
					answers[a].RESPONSE_PERCENT = parseFloat(answers[a].RESPONSE_PERCENT);
					//answers[a].RESPONSE_OTHER = answers[a].ANSWER_VALUES.toString();
					answers[a].EXPLODE = false;
				}
				return answers;
			}
	
			<cfoutput>
				var questions = #SerializeJSON(evaluations)#;
			</cfoutput>
			
			var pieLabelTemplate = "#= dataItem.ANSWER# - #= dataItem.RESPONSE_PERCENT#%";
			var pieLegendTemplate = "#= dataItem.ANSWER# - #= dataItem.RESPONSE_PERCENT#%";
			//var pieTooltipTemplate = "#= dataItem.ANSWER# - #= dataItem.RESPONSE_COUNT#";
			var pieTooltipTemplate = "#= dataItem.RESPONSE_COUNT# responses = #= dataItem.RESPONSE_PERCENT#%";
			var barLabelTemplate = "#= dataItem.ANSWER# - #= dataItem.RESPONSE_PERCENT#%";
			var barLegendTemplate = "#= text#";
			var barTooltipTemplate = "#= dataItem.RESPONSE_COUNT# responses = #= dataItem.RESPONSE_PERCENT#%";
			var labelFont = "12px Arial,Helvetical,sans-serif";
			var legendFont = "12px Arial,Helvetical,sans-serif";
			var tooltipFont = "12px Arial,Helvetical,sans-serif";
			
			renderPieChart = function(q) {
				var question = questions[q-1];
				var answers = parseAnswers(question.ANSWERS);
				$("#q" + q + "Chart").kendoChart({
					theme: $(document).data("kendoSkin") || "blueopal",
					dataSource: answers,
					series: [{
						type: "pie",
						field: "RESPONSE_PERCENT",
						categoryField: "ANSWER",
						explodeField: "EXPLODE",
						labels: {
							visible: false,
							align: "circle",
							font: labelFont,
							template: pieLabelTemplate,
							distance: 0
						},
						padding: 0
					}],
					legend: {
						visible: false,
						position: "left",
						labels: {
							font: legendFont,
							template: pieLegendTemplate
						}
					},
					tooltip: {
						visible: true,
						font: tooltipFont,
						template: pieTooltipTemplate
					}
				})
			}
			
			renderBarChart = function(q) {
				var question = questions[q-1];
				var answers = parseAnswers(question.ANSWERS);
				$("#q" + q + "Chart").kendoChart({
					theme: $(document).data("kendoSkin") || "metro",
					dataSource: answers,
					plotArea: {
						margin: {
							right: 200
						}
					},
					series: [{
						type: "bar",
						field: "RESPONSE_PERCENT",
						categoryField: "ANSWER",
						labels: {visible: true, font: labelFont, template: barLabelTemplate, position: "outsideEnd"},
						missingValue: "zero",
						gap: 0.4,
						spacing: 0.2,
						markers: {visible: true, border: {width: 2, size: 6}},
						padding: 50
					}],
					valueAxis: {
						title: {visible: false, text: "valueAxis"},
						labels: {template: "#= value#%"},
						majorGridLines: {visible: true, color: "gray"},
						majorTicks: {visible: true, color: "gray"},
						minorGridLines: {visible: false, color: "silver"},
						minorTicks: {visible: false, color: "silver"},
						plotBands: [{
							from: 49,
							to: 51,
							color: "gray",
							opacity: 0.3
						}]
					},
					categoryAxis: {
						title: {visible: false, text: "categoryAxis"},
						majorGridLines: {visible: false},
						majorTicks: {visible: false}
					},
					legend: {
						visible: false,
						position: "left",
						labels: {font: legendFont, template: barLegendTemplate}
					},
					tooltip: {
						visible: true,
						font: tooltipFont,
						template: barTooltipTemplate
					}
				})
			}
	
			initialize = function() {
				// Using spreadsheet as underlying table.  Change to Fusion Tables.
				var query = new google.visualization.Query('https://spreadsheets.google.com/pub?key=pCQbetd-CptF0r8qmCOlZGg');
				query.send(draw);
			}
			
			/*draw = function(response) {
				if (response.isError()) {
					alert('Error in query');
				}
				
				var ticketsData = response.getDataTable();
				var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
				chart.draw(ticketsData, {'isStacked': true, 'legend': 'bottom',	'vAxis': {'title': 'Number of tickets'}});
			
				var geoData = new google.visualization.DataTable();
				geoData.addColumn('string', 'City');
				geoData.addColumn('string', 'Name');
				geoData.addColumn('boolean', 'Food');
				geoData.addRows(3);
				geoData.setCell(0, 0, 'London');
				geoData.setCell(1, 0, 'Paris');
				geoData.setCell(2, 0, 'Moscow');
				geoData.setCell(0, 1, 'Cinematics London');
				geoData.setCell(1, 1, 'Cinematics Paris');
				geoData.setCell(2, 1, 'Cinematics Moscow');
				geoData.setCell(0, 2, true);
				geoData.setCell(1, 2, true);
				geoData.setCell(2, 2, false);
			
				var geoView = new google.visualization.DataView(geoData);
				geoView.setColumns([0, 1]);
				
				var table = new google.visualization.Table(document.getElementById('table_div'));
				table.draw(geoData, {showRowNumber: false});
				
				var map = new google.visualization.Map(document.getElementById('map_div'));
				map.draw(geoView, {showTip: true});
			
				// Set a 'select' event listener for the table.
				// When the table is selected,
				// we set the selection on the map.
				google.visualization.events.addListener(table, 'select',
					function() {
						map.setSelection(table.getSelection());
					}
				);
				
				// Set a 'select' event listener for the map.
				// When the map is selected,
				// we set the selection on the table.
				google.visualization.events.addListener(map, 'select',
					function() {
						table.setSelection(map.getSelection());
					}
				);
			};
			
			google.load('visualization', '1', {'packages': ['table', 'map', 'corechart']});
				
			google.setOnLoadCallback(initialize);*/

			$(function() {
				var pieCharts = "1,2,3,4,5,7,10,11,12,13,15,17,19";
				var barCharts = "6,9,14,16,18";
				var pieChartsArray = pieCharts.split(",");
				var barChartsArray = barCharts.split(",");
				if (pieChartsArray.length > 0) {
					for (var q = 0; q < pieChartsArray.length; q++) {
						renderPieChart(pieChartsArray[q]);
					}
				}
				if (barChartsArray.length > 0) {
					for (var q = 0; q < barChartsArray.length; q++) {
						renderBarChart(barChartsArray[q]);
					}
				}
			});
		//-->
		</script>

		<style type="text/css">
			.k-chart {
				width: 200px;
				height: 150px;
			}
		</style>

		<cfoutput>
		
			<!--- <div class="row-fluid" style="margin-bottom: 10px;">
				<div class="span12">
					<a id="filterLink" href="##" class="btn" onclick="toggleFilter('filter')">Show filters</a>
					<span class="pull-right"><strong>Count:</strong> #evaluationCount#</span>
				</div>
			</div>
		
			<div id="filter" class="alert alert-info alert-block" style="display: none;">
				<div class="span12">
					<div class="well well-framed">
						<cfform name="evaluationsForm" id="evaluationsForm" action="#script_name#" method="post">
							<cfinput type="hidden" name="view" value="#view#">
							<div class="row-fluid">
								<div class="span12">
									<h4>Filters</h4>
									<table cellpadding="6">
										<tr valign="top">
											<td>
												<label>Program Year</label>
												<cfselect name="filterProgramYear" size="1" multiple="false" required="yes" message="Program Year filter is required">
													<cfloop index="y" from="2012" to="#ListFirst(application.currentProgramYear, '-')#">
														<cfset py = "#y#-" & y+1>
														<option value="#py#"<cfif client.howDidWeDo.programYears eq py> selected</cfif>>#py#</option>
													</cfloop>
												</cfselect>
											</td>
											<cfif IsUserInRole("Super User")>
												<td>
													<label>Regions</label>
													<cfselect name="filterRegionIDs" size="1" multiple="false" required="yes" message="Region filter is required">
														<option value="All"<cfif client.howDidWeDo.regionIDs eq "All"> selected</cfif>>All</option>
														<cfloop query="regions">
															<option value="#Region_ID#"<cfif ListFind(client.howDidWeDo.regionIDs, Region_ID)> selected</cfif>>#Region_ID#</option>
														</cfloop>
													</cfselect>
												</td>
											</cfif>
										<!--- <tr>
											<td>
												<label>County</label>
												<cfselect name="filterCountyIDs" size="1" multiple="false" required="yes" message="County filter is required">
													<option value="All"<cfif client.howDidWeDo.countyIDs eq "All"> selected</cfif>>All</option>
													<cfloop query="counties">
														<option value="#County_ID#"<cfif ListFind(client.howDidWeDo.countyIDs, County_ID)> selected</cfif>>#County#</option>
													</cfloop>
												</cfselect>
											</td>
										</tr>
										<tr>
											<td>
												<label>School District</label>
												<cfselect name="filterDistrictIDs" size="1" multiple="false" required="yes" message="School District filter is required">
													<option value="All">All</option>
													<option>Coming soon</option>
												</cfselect>
											</td>
										</tr>
										<tr>
											<td>
												<label>School</label>
												<cfselect name="filterSchoolIDs" size="1" multiple="false" required="yes" message="School filter is required">
													<option value="All">All</option>
													<option>Coming soon</option>
												</cfselect>
											</td> --->
											<td>
												<label>Organizations</label>
												<cfselect name="filterOrganizationIDs" size="7" multiple="true" required="yes" message="Organization filter is required" style="width: auto;">
													<option value="All"<cfif client.howDidWeDo.organizationIDs eq "All"> selected</cfif>>All</option>
													<cfloop query="organizations">
														<option value="#Organization_ID#"<cfif ListFind(client.howDidWeDo.organizationIDs, Organization_ID)> selected</cfif>>#Organization# - #City#</option>
													</cfloop>
												</cfselect>
											</td>
											<!--- <td>
												<label>Follow Up</label>
												<cfif client.students.programYears neq "All" and client.students.programYears gte "2012-2013">
													<cfselect name="filterFollowUp" size="1" multiple="false" required="yes" message="Follow Up filter is required">
														<option value="All"<cfif client.students.followUp eq "All"> selected</cfif>>All</option>
														<option value="Yes"<cfif client.students.followUp eq "Yes"> selected</cfif>>Yes</option>
														<option value="No"<cfif client.students.followUp eq "No"> selected</cfif>>No</option>
													</cfselect>
												<cfelse>
													<span class="muted"><small>Not available as filtered</small></span>
												</cfif>
											</td>
											<td>
												<label>Follow Up Status</label>
												<cfif client.students.programYears neq "All" and client.students.programYears gte "2012-2013">
													<cfselect name="filterFollowUpStatus" size="1" multiple="false" required="yes" message="Follow Up Status filter is required">
														<option value="All"<cfif client.students.followUpStatus eq "All"> selected</cfif>>All</option>
														<option value="Complete"<cfif client.students.followUpStatus eq "Complete"> selected</cfif>>Complete</option>
														<option value="Not Complete"<cfif client.students.followUpStatus eq "Not Complete"> selected</cfif>>Not Complete</option>
													</cfselect>
												<cfelse>
													<span class="muted"><small>Not available as filtered</small></span>
												</cfif>
											</td> --->
										</tr>
										<tr>
											<td colspan="5">
												<button type="submit" class="btn btn-info">Apply</button> <a href="#script_name#?view=workshops&resetFilters=true" class="btn btn-info">Clear</a>
											</td>
										</tr>
									</table>
								<!--- </div>
								<div class="span8">
									<table cellpadding="6" border="0">
										<tr>
											<td colspan="2">
												<label>Dimension 1</label>
												<cfselect name="dimension1" size="1" multiple="false" required="yes" message="Dimention 1 is required" style="width: auto;">
													<option value="1">FAFSAs submitted and completed</option>
													<option value="2">E1 FAFSAs submitted and completed</option>
													<option value="3">Cal Grant GPAs submitted by March 2 deadline</option>
													<option value="4">Entitlement Cal Grant applications and awards offered</option>
													<option value="5">Entitlement E1 Cal Grant applications and awards offered</option>
													<option value="6">E1 Enrollment</option>
													<option value="7">E1 Cal Grant Champion schools</option>
													<option value="7">E1 Cal Grant Champion districts</option>
													<option value="8">Total state and federal funds...</option>
													<cfloop index="q" from="1" to="#ArrayLen(evaluations)#">
														<option value="#q#"<cfif q eq 11> selected</cfif>>#evaluations[q].Question#</option>
													</cfloop>
												</cfselect>
											</td>
										</tr>
										<tr>
											<td colspan="2">
												<label>Dimension 2</label>
												<cfselect name="dimension2" size="1" multiple="false" required="yes" message="Dimention 2 is required" style="width: auto;">
													<option value="None">None</option>
													<option value="1">FAFSAs submitted and completed</option>
													<option value="2">E1 FAFSAs submitted and completed</option>
													<option value="3">Cal Grant GPAs submitted by March 2 deadline</option>
													<option value="4">Entitlement Cal Grant applications and awards offered</option>
													<option value="5">Entitlement E1 Cal Grant applications and awards offered</option>
													<option value="6">E1 Enrollment</option>
													<option value="7">E1 Cal Grant Champion schools</option>
													<option value="7">E1 Cal Grant Champion districts</option>
													<option value="8">Total state and federal funds...</option>
													<cfloop index="q" from="1" to="#ArrayLen(evaluations)#">
														<option value="#q#"<cfif q eq 12> selected</cfif>>#evaluations[q].Question#</option>
													</cfloop>
												</cfselect>
											</td>
										</tr>
										<tr>
											<td colspan="2">
												<label>Dimension 3</label>
												<cfselect name="dimension3" size="1" multiple="false" required="yes" message="Dimention 2 is required" style="width: auto;">
													<option value="None">None</option>
													<option value="1">FAFSAs submitted and completed</option>
													<option value="2">E1 FAFSAs submitted and completed</option>
													<option value="3">Cal Grant GPAs submitted by March 2 deadline</option>
													<option value="4">Entitlement Cal Grant applications and awards offered</option>
													<option value="5">Entitlement E1 Cal Grant applications and awards offered</option>
													<option value="6">E1 Enrollment</option>
													<option value="7">E1 Cal Grant Champion schools</option>
													<option value="7">E1 Cal Grant Champion districts</option>
													<option value="8">Total state and federal funds...</option>
													<cfloop index="q" from="1" to="#ArrayLen(evaluations)#">
														<option value="#q#">#evaluations[q].Question#</option>
													</cfloop>
												</cfselect>
											</td>
										</tr>
									</table>
								</div> --->
							</div>
							<!--- <div class="row-fluid">
								<div class="span12">
									<button type="submit" class="btn btn-primary">Apply</button><!---  <a href="#script_name#?view=exitSurveys&resetFilters=true" class="btn btn-info">Clear</a> --->
								</div>
							</div> --->
						</cfform>
					</div>
				</div>
			</div> --->

					<!--- <div id="table_div" class="clearfix" style="width: 100%; height: 400px;"></div>
					<div id="chart_div" class="clearfix" style="width: 100%; height: 400px;"></div> --->
					<!--- <div class="accordion" id="esAccordian">
						<cfloop index="q" from="1" to="#ArrayLen(evaluations)#">
							<cfset totalExitSurveys = evaluations[q].Response_Count + evaluations[q].No_Response_Count />
							<cfset noResponsePercent = evaluations[q].No_Response_Count / totalExitSurveys * 100 />
							<cfset multiResponsePercent = evaluations[q].Multi_Response_Count / totalExitSurveys * 100 />
							<div class="accordion-group">
								<div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="##esAccordian" href="##p#q#">#q#. #evaluations[q].Question#</a> </div>
								<div id="p#q#" class="accordion-body collapse<cfif q eq 1> in</cfif>">
									<div class="accordion-inner">
										<cfif q eq 8>
											Data can not be charted.
										<cfelse>
											<ul class="nav nav-pills">
												<li class="active"><a href="##table#q#" data-toggle="pill">Table</a></li>
												<li><a href="##chart#q#" data-toggle="pill">Chart</a></li>
											</ul>
											<div class="tab-content">
												<div class="tab-pane active" id="table#q#">
													<table class="table table-hover table-bordered">
														<thead>
															<th>Answer</th>
															<th>Count</th>
															<th>Percent</th>
														</thead>
														<tbody>
															<cfloop index="a" from="1" to="#ArrayLen(evaluations[q].Answers)#">
																<tr>
																	<td>#evaluations[q].Answers[a].Answer#</td>
																	<td>#evaluations[q].Answers[a].Response_Count#</td>
																	<td>#evaluations[q].Answers[a].Response_Percent#%</td>
																</tr>
															</cfloop>
															<tr>
																<td>Did not respond</td>
																<td>#evaluations[q].No_Response_Count#</td>
																<td>#DecimalFormat(noResponsePercent)#%</td>
															</tr>
															<cfif evaluations[q].Question_Type eq "Multiple select">
																<tr>
																	<td>Multiple responses</td>
																	<td>#evaluations[q].Multi_Response_Count#</td>
																	<td>#DecimalFormat(multiResponsePercent)#%</td>
																</tr>
															</cfif>
														</tbody>
													</table>
												</div>
												<div class="tab-pane" id="chart#q#">
													<div id="q#q#Chart"></div>
												</div>
											</div>
										</cfif>
									</div>
								</div>
							</div>
						</cfloop>
					</div> --->
					
					
					
			<div class="row-fluid">
				<div class="span6">		
					<cfset dim = 1>
					<cfloop index="q" from="11" to="12">
						<cfset totalExitSurveys = evaluations[q].Response_Count + evaluations[q].No_Response_Count />
						<cfset noResponsePercent = evaluations[q].No_Response_Count / totalExitSurveys * 100 />
						<cfset multiResponsePercent = evaluations[q].Multi_Response_Count / totalExitSurveys * 100 />
						
						<h4>Dimension #dim# - #evaluations[q].Question#</h4>
						
						<div class="row-fluid">
							<div class="span8">
								<table class="table table-hover table-bordered">
									<thead>
										<th>Answer</th>
										<th>Count</th>
										<th>Percent</th>
									
									<tbody>
										<cfloop index="a" from="1" to="#ArrayLen(evaluations[q].Answers)#">
											<tr>
												<td>#evaluations[q].Answers[a].Answer#</td>
												<td>#evaluations[q].Answers[a].Response_Count#</td>
												<td>#evaluations[q].Answers[a].Response_Percent#%</td>
											</tr>
										</cfloop>
										<tr>
											<td>Did not respond</td>
											<td>#evaluations[q].No_Response_Count#</td>
											<td>#DecimalFormat(noResponsePercent)#%</td>
										</tr>
										<cfif evaluations[q].Question_Type eq "Multiple select">
											<tr>
												<td>Multiple responses</td>
												<td>#evaluations[q].Multi_Response_Count#</td>
												<td>#DecimalFormat(multiResponsePercent)#%</td>
											</tr>
										</cfif>
									</tbody>
								</table>
							</div>
							<div class="span4">
								<div id="q#q#Chart"></div>
							</div>
						</div>
						<cfif dim eq 2>
							<h4>Dimension 1 x Dimension 2</h4>
							
							<div class="row-fluid">
								<div class="span8">
									<table class="table table-hover table-bordered">
									<thead>
										<th>D1 Answer</th>
										<th>D2 Answer</th>
										<th>Count</th>
										<th>Percent</th>
									
									<tbody>
										
											<tr>
												<td>Male</td>
												<td>American Indian or Alaskan Native</td>
												<td>46</td>
												<td>1.96%</td>
											</tr>
											<tr>
												<td>Female</td>
												<td>American Indian or Alaskan Native</td>
												<td>46</td>
												<td>1.96%</td>
											</tr>
											
											<tr>
												<td>Male</td>
												<td>Asian</td>
												<td>112</td>
												<td>4.77%</td>
											</tr>
											<tr>
												<td>Female</td>
												<td>Asian</td>
												<td>112</td>
												<td>4.77%</td>
											</tr>
										
											<tr>
												<td>Male</td>
												<td>Black/African American</td>
												<td>104</td>
												<td>4.43%</td>
											</tr>
											<tr>
												<td>Female</td>
												<td>Black/African American</td>
												<td>104</td>
												<td>4.43%</td>
											</tr>
										
											<tr>
												<td>Male</td>
												<td>Hispanic/Latino</td>
												<td>1779</td>
												<td>75.73%</td>
											</tr>
											<tr>
												<td>Female</td>
												<td>Hispanic/Latino</td>
												<td>1779</td>
												<td>75.73%</td>
											</tr>
										
											<tr>
												<td>Male</td>
												<td>Native Hawaiian or other Pacific Islander</td>
												<td>23</td>
												<td>0.98%</td>
											</tr>
											<tr>
												<td>Female</td>
												<td>Native Hawaiian or other Pacific Islander</td>
												<td>23</td>
												<td>0.98%</td>
											</tr>
										
											<tr>
												<td>Male</td>
												<td>White</td>
												<td>423</td>
												<td>18.01%</td>
											</tr>
											<tr>
												<td>Female</td>
												<td>White</td>
												<td>423</td>
												<td>18.01%</td>
											</tr>
										
											<tr>
												<td>Male</td>
												<td>Other</td>
												<td>37</td>
												<td>1.58%</td>
											</tr>
											<tr>
												<td>Female</td>
												<td>Other</td>
												<td>37</td>
												<td>1.58%</td>
											</tr>
										
											<tr>
												<td>Male</td>
												<td>Decline to answer</td>
												<td>29</td>
												<td>1.23%</td>
											</tr>
											<tr>
												<td>Female</td>
												<td>Decline to answer</td>
												<td>29</td>
												<td>1.23%</td>
											</tr>
										
										<tr>
											<td>Male</td>
											<td>Did not respond</td>
											<td>27</td>
											<td>1.14%</td>
										</tr>
										<tr>
											<td>Female</td>
											<td>Did not respond</td>
											<td>27</td>
											<td>1.14%</td>
										</tr>
										
											<tr>
												<td>Male</td>
												<td>Multiple responses</td>
												<td>177</td>
												<td>7.45%</td>
											</tr>
											<tr>
												<td>Female</td>
												<td>Multiple responses</td>
												<td>177</td>
												<td>7.45%</td>
											</tr>
										
									</tbody>
								</table>
								</div>
								<div class="span4">
									<div class="well well-framed">
										Chart
									</div>
								</div>
							</div>
						</cfif>
						<cfset dim++ />
					</cfloop>
					
				</div>
				<div class="span6">
				
					<ul class="nav nav-tabs">
						<li class="active"><a href="##districtMap" data-toggle="tab">Districts</a></li>
						<li><a href="##schoolMap" data-toggle="tab">Schools</a></li>
						<!--- <li><a href="##countyMap">Counties</a></li> --->
					</ul>
					<div class="tab-content">
						<div class="tab-pane active" id="districtMap">
					
							<iframe 	width="100%" 
										height="800" 
										frameborder="0" 
										scrolling="no" 
										marginheight="0" 
										marginwidth="0" 
										src="https://www.google.com/fusiontables/embedviz?q=select+col2+from+1duB6hyn5n1ukEWBrhbyCK0U1T_ufWC0m26E0QKA&amp;viz=MAP&amp;h=false&amp;lat=37.41896824258246&amp;lng=-119.30660499999999&amp;t=1&amp;z=6&amp;l=col2"></iframe>
									
						</div>		
						<div class="tab-pane" id="schoolMap">		
							<iframe 	width="100%" 
										height="800" 
										frameborder="0" 
										scrolling="no" 
										marginheight="0" 
										marginwidth="0" 
										src="https://www.google.com/fusiontables/embedviz?q=select+col2+from+1z9zka5upPaG2QDp53pUZPLvxdsrMbxVTMaxEn34&amp;viz=MAP&amp;h=false&amp;lat=37.41896824258246&amp;lng=-119.30660499999999&amp;t=1&amp;z=6&amp;l=col2"></iframe>
						</div>			
						<!--- <div id="map_div" style="width: 100%; height: 100%;"></div> --->
					</div>
				</div>
			</div>
		
		</cfoutput>
		<!---<iframe width="500" height="300" scrolling="no" frameborder="no" src="https://www.google.com/fusiontables/embedviz?q=select+col2+from+1z9zka5upPaG2QDp53pUZPLvxdsrMbxVTMaxEn34&amp;viz=MAP&amp;h=false&amp;lat=37.660996516345364&amp;lng=-117.67721371049997&amp;t=1&amp;z=6&amp;l=col2"></iframe> <iframe width="500" height="300" scrolling="no" frameborder="no" src="https://www.google.com/fusiontables/embedviz?q=select+col2+from+1duB6hyn5n1ukEWBrhbyCK0U1T_ufWC0m26E0QKA&amp;viz=MAP&amp;h=false&amp;lat=37.41896824258246&amp;lng=-119.30660499999999&amp;t=1&amp;z=6&amp;l=col2"></iframe>
		// School Districts
		https://www.google.com/fusiontables/DataSource?snapid=S107070198FJ
		// Public schools
		https://www.google.com/fusiontables/DataSource?snapid=S1070801g4Pc --->
	<cfelse>
	
		<div class="alert alert-info notFound">No data</div>

		<script type="text/javascript" language="javascript">
		<!--
			$(function() {
				$("#filter").show();
			});
		// -->
		</script>
		
	</cfif>

<cfelseif IsUserInRole("Organizer") or IsUserInRole("Site Contact")>

	Coming soon

	<!--- <cfparam name="programYears" type="string" default="#request.currentProgramYear#" />
	<cfparam name="workshopIDs" type="string" default="All" />
	
	<cfscript>
		workshopGateway = new assets.calgrants.com.gateway.WorkshopGateway();
		workshops = workshopGateway.query(Program_Year = programYears, regionIDs = IIf(IsUserInRole("Regional Admin"), request.authUser.regionID, ""), Organization_ID = IIf(IsUserInRole("Organizer") OR IsUserInRole("Site Contact"), request.authUser.organizationID, ""), Manager_ID = IIf(IsUserInRole("Site Contact"), request.authUser.userID, ""));
		evaluationGateway = new assets.calgrants.com.gateway.EvaluationGateway();
		evaluations = evaluationGateway.report(organizationIDs = IIf(IsUserInRole("Organizer") OR IsUserInRole("Site Contact"), request.authUser.organizationID, ""), workshopIDs = IIf(ListFind(workshopIDs, "All") eq 0 AND Len(Trim(workshopIDs)) gt 0, DE(workshopIDs), ""), managerIDs = IIf(IsUserInRole("Site Contact"), request.authUser.userID, ""), programYears = programYears);
	</cfscript>

	<cfif workshops.RecordCount gt 0>
	
		<cfset totalEvaluations = 0 />
		<cfset totalWorkshops = workshops.RecordCount/>
		<cfset validWorkshops = 0 />
		<cfset workshopsArray = ArrayNew(1) />
		<cfset selectedEvaluations = 0 />
		<cfset selectedWorkshops = 0 />
		<!--- <cfset selectedWorkshopIDs = "" /> --->
		<cfset selectedWorkshopsArray = ArrayNew(1) />
		<cfloop query="workshops">
			<cfset totalEvaluations = totalEvaluations + Student_Count />
			<cfif Student_Count gt 0>
				<cfset validWorkshops = IncrementValue(validWorkshops) />
			</cfif>
			<cfset workshopStruct = StructNew() />
			<cfset workshopStruct.workshopID = Workshop_ID />
			<cfset workshopStruct.workshop = "#Site#, #DateFormat(Workshop_Date, 'm/d/yyyy')# #TimeFormat(Start_Time, 'h:mmtt')#-#TimeFormat(End_Time, 'h:mmtt')#" />
			<cfset workshopStruct.studentCount = Student_Count />
			<cfif (ListFind(workshopIDs, "All") gt 0 OR ListFind(workshopIDs, Workshop_ID) gt 0) AND Student_Count gt 0>
				<cfset selectedEvaluations = selectedEvaluations + Student_Count />
				<cfset selectedWorkshops = IncrementValue(selectedWorkshops) />
				<!--- <cfset selectedWorkshopIDs = ListAppend(selectedWorkshopIDs, Workshop_ID) /> --->
				<cfset workshopStruct.selected = true />
			<cfelse>
				<cfset workshopStruct.selected = false />
			</cfif>
			<cfset ArrayAppend(workshopsArray, workshopStruct) />
		</cfloop>
		
		<cfform id="selectWorkshopsForm" action="#script_name#" method="post">
			<cfinput type="hidden" name="view" value="#view#" />
			
			<cfoutput>
			
				<p><a href="##" id="filterButton" class="btn btn-success" onclick="filter(); return false;">Filter</a><span id="cancelFilterButton" style="display: none;">&nbsp;<a href="" class="btn btn-success" onclick="cancelFilter(); return false;">Cancel</a></span><span id="applyFilterButton" style="display: none;">&nbsp;<cfinput type="submit" name="applyButton" class="btn btn-success" value="Apply" /></span>&nbsp;<a id="exportButton" href="?action=export&collection=evaluations&workshopIDs=#workshopIDs#" target="_new" class="btn btn-success">Export Exit Surveys</a></p>
	
				<table id="workshopsTable" class="table table-hover table-bordered">
					<thead>
						<tr>
							<th class="checkboxCol"></th>
							<th>Workshop</th>
							<th>Exit Surveys</th>
						</tr>
					</thead>
					<tbody>
						<cfloop index="w" from="1" to="#ArrayLen(workshopsArray)#">
							<tr class="#IIf(workshopsArray[w].selected, DE('selected'), DE('unselected'))#">
								<td class="checkboxCol">
									<cfif workshopsArray[w].studentCount gt 0>
										<input type="checkbox" name="workshopIDs" value="#workshopsArray[w].workshopID#"<cfif ListFind(workshopIDs, "All") gt 0 OR ListFind(workshopIDs, workshopsArray[w].workshopID) gt 0> class="selectedWorkshop" checked</cfif>>
									</cfif>
								</td>
								<td>#workshopsArray[w].workshop#</td>
								<td style="width: 100px;">#workshopsArray[w].studentCount#</td>
							</tr>
						</cfloop>
					</tbody>
				</table>
				
			</cfoutput>
			
		</cfform>
	
		<script type="text/javascript">
			
			var filter = function() {
				$("#filterButton").hide();
				$("#cancelFilterButton").show();
				$("#applyFilterButton").show();
				$(".unselected").show();
				$(".checkboxCol").show();
				$("#exportButton").hide();
			}
			
			var cancelFilter = function() {
				$("#cancelFilterButton").hide();
				$("#filterButton").show();
				$("#applyFilterButton").hide();
				$(".unselected").hide();
				$(".checkboxCol").hide();
				$("#exportButton").show();
				$.each($(".selectedWorkshop"), function(i,e) {
					e.checked = true;
				});
				//var workshopCheckboxes = $(".workshopCheckboxes");
				//for (var i = 0; i < selectedWorkshopIDs.length; i++) {
					//if (selectedWorkshopIDs[i].val()	
				//}
			}
			
			var toggleOthers = function(e) {
				if (e.checked) {
					$(".otherCheckbox").prop("checked", false);
				}
			}
			
			var toggleAll = function(e) {
				if (e.checked) {
					$(".allCheckbox").prop("checked", false);
				}
			}							
			
			$(function() {
				$(".unselected").hide();
				$(".checkboxCol").hide();
			})
		</script>
		
		<cfif ArrayLen(evaluations) gt 0>
		
			<script type="text/javascript">
				
				var parseQuestions = function(questions) {
					for (var q = 0; q < questions.length; q++) {
						questions[q].QUESTION_NUMBER = parseInt(questions[q].QUESTION_NUMBER);
						questions[q].RESPONSE_COUNT = parseInt(questions[q].RESPONSE_COUNT);
						questions[q].MULTI_RESPONSE_COUNT = parseInt(questions[q].MULTI_RESPONSE_COUNT);
						questions[q].NO_RESPONSE_COUNT = parseInt(questions[q].NO_RESPONSE_COUNT);
					}
					return questions;
				}
				
				var parseAnswers = function(answers) {
					for (var a = 0; a < answers.length; a++) {
						if (answers[a].ANSWER === true) {
							answers[a].ANSWER = "Yes ";
						} else if (answers[a].ANSWER === false) {
							answers[a].ANSWER = "No ";
						}
						answers[a].ANSWER_NUMBER = parseInt(answers[a].ANSWER_NUMBER);
						answers[a].RESPONSE_COUNT = parseInt(answers[a].RESPONSE_COUNT);
						answers[a].RESPONSE_PERCENT = parseFloat(answers[a].RESPONSE_PERCENT);
						//answers[a].RESPONSE_OTHER = answers[a].ANSWER_VALUES.toString();
						answers[a].EXPLODE = false;
					}
					return answers;
				}
		
				<cfoutput>
					var questions = #SerializeJSON(evaluations)#;
				</cfoutput>
				
				var pieLabelTemplate = "#= dataItem.ANSWER# - #= dataItem.RESPONSE_PERCENT#%";
				var pieLegendTemplate = "#= dataItem.ANSWER# - #= dataItem.RESPONSE_PERCENT#%";
				//var pieTooltipTemplate = "#= dataItem.ANSWER# - #= dataItem.RESPONSE_COUNT#";
				var pieTooltipTemplate = "#= dataItem.RESPONSE_COUNT# responses = #= dataItem.RESPONSE_PERCENT#%";
				var barLabelTemplate = "#= dataItem.ANSWER# - #= dataItem.RESPONSE_PERCENT#%";
				var barLegendTemplate = "#= text#";
				var barTooltipTemplate = "#= dataItem.RESPONSE_COUNT# responses = #= dataItem.RESPONSE_PERCENT#%";
				var labelFont = "12px Arial,Helvetical,sans-serif";
				var legendFont = "12px Arial,Helvetical,sans-serif";
				var tooltipFont = "12px Arial,Helvetical,sans-serif";
				
				renderPieChart = function(q) {
					var question = questions[q-1];
					var answers = parseAnswers(question.ANSWERS);
					$("#q" + q + "Chart").kendoChart({
						theme: $(document).data("kendoSkin") || "metro",
						dataSource: answers,
						series: [{
							type: "pie",
							field: "RESPONSE_PERCENT",
							categoryField: "ANSWER",
							explodeField: "EXPLODE",
							labels: {
								visible: true,
								align: "circle",
								font: labelFont,
								template: pieLabelTemplate,
								distance: 20
							},
							//padding: 0
						}],
						legend: {
							visible: false,
							position: "left",
							labels: {
								font: legendFont,
								template: pieLegendTemplate
							}
						},
						tooltip: {
							visible: true,
							font: tooltipFont,
							template: pieTooltipTemplate
						}
					})
				}
				
				renderBarChart = function(q) {
					var question = questions[q-1];
					var answers = parseAnswers(question.ANSWERS);
					$("#q" + q + "Chart").kendoChart({
						theme: $(document).data("kendoSkin") || "metro",
						dataSource: answers,
						series: [{
							type: "bar",
							field: "RESPONSE_PERCENT",
							categoryField: "ANSWER",
							labels: {visible: true, font: labelFont, template: barLabelTemplate, position: "outsideEnd"},
							missingValue: "zero",
							gap: 0.4,
							spacing: 0.2,
							markers: {visible: true, border: {width: 2, size: 6}},
							//padding: 0
						}],
						valueAxis: {
							title: {visible: false, text: "valueAxis"},
							labels: {template: "#= value#%"},
							majorGridLines: {visible: true, color: "gray"},
							majorTicks: {visible: true, color: "gray"},
							minorGridLines: {visible: true, color: "silver"},
							minorTicks: {visible: true, color: "silver"},
							plotBands: [{
								from: 49,
								to: 51,
								color: "gray",
								opacity: 0.3
							}]
						},
						categoryAxis: {
							title: {visible: false, text: "categoryAxis"},
							majorGridLines: {visible: false},
							majorTicks: {visible: false}
						},
						legend: {
							visible: false,
							position: "left",
							labels: {font: legendFont, template: barLegendTemplate}
						},
						tooltip: {
							visible: true,
							font: tooltipFont,
							template: barTooltipTemplate
						}
					})
				}
		
				$(function() {
					var pieCharts = "1,2,3,4,5,7,10,11,13,15,17,19";
					var barCharts = "6,9,12,14,16,18";
					var pieChartsArray = pieCharts.split(",");
					var barChartsArray = barCharts.split(",");
					if (pieChartsArray.length > 0) {
						for (var q = 0; q < pieChartsArray.length; q++) {
							renderPieChart(pieChartsArray[q]);
						}
					}
					if (barChartsArray.length > 0) {
						for (var q = 0; q < barChartsArray.length; q++) {
							renderBarChart(barChartsArray[q]);
						}
					}
				})
			
			</script>
			<style type="text/css">
				.k-chart {
					width: 600px;
					height: 400px;
				}
			</style>
			<div class="accordion" id="esAccordian">
				<cfoutput>
					<cfloop index="q" from="1" to="#ArrayLen(evaluations)#">
						<div class="accordion-group">
							<div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="##esAccordian" href="##p#q#">#q#. #evaluations[q].Question#</a> </div>
							<div id="p#q#" class="accordion-body collapse<cfif q eq 1> in</cfif>">
								<div class="accordion-inner">
									<table class="table table-hover table-bordered">
										<tr>
											<th>Responses</th>
											<td>#evaluations[q].Response_Count#</td>
										</tr>
										<tr>
											<th>Non-responses</th>
											<td>#evaluations[q].No_Response_Count#</td>
										</tr>
										<cfif evaluations[q].Question_Type eq "Multiple select">
											<tr>
												<th>Multi-responses</th>
												<td>#evaluations[q].Multi_Response_Count#</td>
											</tr>
										</cfif>
									</table>
									<cfif q eq 8>
										Data can not be charted. 
									<cfelse>
										<ul class="nav nav-pills">
											<li class="active"><a href="##table#q#" data-toggle="pill">Table</a></li>
											<li><a href="##chart#q#" data-toggle="pill">Chart</a></li>
										</ul>
										<div class="tab-content">
											<div class="tab-pane active" id="table#q#">
												<table class="table table-hover table-bordered">
													<thead>
														<th>Answer</th>
														<th>Count</th>
														<th>Percent</th>
													</thead>
													<tbody>
														<cfloop index="a" from="1" to="#ArrayLen(evaluations[q].Answers)#">
															<tr>
																<td>#evaluations[q].Answers[a].Answer#</td>
																<td>#evaluations[q].Answers[a].Response_Count#</td>
																<td>#evaluations[q].Answers[a].Response_Percent#%</td>
															</tr>
														</cfloop>
													</tbody>
												</table>
											</div>
											<div class="tab-pane" id="chart#q#">
												<div id="q#q#Chart"></div>
											</div>
										</div>
									</cfif>
								</div>
							</div>
						</div>
					</cfloop>
				</cfoutput>
			</div>
			
		<cfelse>
		
			<p>No exit surveys found</p>
			
		</cfif>
		
	<cfelseif workshops.RecordCount eq 0>
	
		<p>No workshops found</p>
		
	</cfif> --->
	
</cfif>